﻿#ifndef FUNCTION_H
#define FUNCTION_H

#include <person.h>
#include <type_traits>


//函数：功能是升级斗之气等级, 默认只能升一级
template <typename T>
void level_up(T & anyone){

    //斗气等级提升
    anyone.level = anyone.level + 1;
}

//函数：功能是升级斗之气等级，指定生几级
template <typename T>
void level_up(T & anyone, const int value){

    //斗气等级提升
    anyone.level = anyone.level + value;
}

void test_survival_period(){
    Person<double> xuner("xiaoyan2",18,9); //萧炎
}


//数组作为参数
void print_all_skill(Skill skill_set[],int count){

    for(int i=0; i<count; i++){
        qDebug() << "skill i " << i
                 << skill_set[i].name;
    }
}


//是否为指针类型
template <typename T>
bool isPointer(T& obj) {
    return std::is_pointer<T>::value;
}


//参数为指针
bool can_find_fire(Person<double>* person){

    if(person->name == "青鳞"){
        return true;
    }
    else{
        return false;
    }
}

//参数作为返回值

Person<double> * who_find_fire(QString fire_name){

    if(fire_name == "青莲地心火"){
        Person<double> *qinglin = new Person<double>("青鳞",13, 5);

        //注意返回的是指针
        return qinglin;
    }

}

#endif // FUNCTION_H
